package net.sharpf2.api.interfaces;

import net.sharpf2.sfcore.client.Interface;
import net.sharpf2.api.game.Interfaces;
import net.sharpf2.api.types.Content;

/**
 * Class to handle the magic tab.
 * @author Piotr Gajdowski
 */
public class Logout {
    
    /**
     * Return the actual interface object for the magic tab.
     * @return Content<Interface>
     */
    public static Content<Interface> getInterface() {
        return Interfaces.get(Constants.LOGOUT_TAB, 0);
    }
    
    /**
     * Returns the children of the magic tab.
     * @param   child   Child ID.
     * @return  Content<Interface>
     */
    public static Content<Interface> getChild(int child) {
        return Interfaces.get(Constants.LOGOUT_TAB, child);
    }
    
    /**
     * Exits to lobby interface.
     */
    public static void exitToLobby() {
        Tabs.checkAndOpen(Tabs.Constants.TAB_LOGOUT);
        Content<Interface> btn = Interfaces.get(Constants.LOGOUT_TAB, Constants.EXIT_LOBBY);
        if (btn != null) {
            btn.getActions().click();
        }
    }
    
    /**
     * Exits to login interface.
     */
    public static void exitToLogin() {
        Tabs.checkAndOpen(Tabs.Constants.TAB_LOGOUT);
        Content<Interface> btn = Interfaces.get(Constants.LOGOUT_TAB, Constants.EXIT_LOGIN);
        if (btn != null) {
            btn.getActions().click();
        }
    }
    
    public static class Constants {
        public static final int LOGOUT_TAB = 182;
        public static final int EXIT_LOBBY = 6;
        public static final int EXIT_LOGIN = 13;
    }
    
}